<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class WorkFlowRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'flow_name' => ['required', Rule::unique('workflows', 'flow_name')->ignore(request()->id)],
            'flow_sort' => 'required|numeric'
        ];
    }

    public function messages()
    {
        return [
            'required' => '必填项',
            'numeric' => '必须为数字',
        ];
    }

    public function attributes()
    {
        return [
            'flow_sort' => '流程排序', 'flow_name' => '流程名称'
        ];
    }
}
